package com.example.utils;

import com.example.entity.*;

import java.util.Iterator;
import java.util.List;

/**
 *
 */
public class RemoveRelation {
    public static void removeEA(Event eventNode, Address addressNode) {
        List<GuanXi_EA> guanXi_eaList = eventNode.getGuanXi_eaList();
        // list的遍历器
        Iterator<GuanXi_EA> iterator = guanXi_eaList.iterator();
        while(iterator.hasNext()){
            GuanXi_EA guanXi_ea = iterator.next();
            if (guanXi_ea.getAddress().getId().longValue() == addressNode.getId().longValue()) {
                iterator.remove();
            }
        }
    }

    public static void removeEK(Event eventNode, KnowledgeElement knowledgeElementNode) {
        List<GuanXi_EK> guanXi_ekList = eventNode.getGuanXi_ekList();
        // list的遍历器
        Iterator<GuanXi_EK> iterator = guanXi_ekList.iterator();
        while(iterator.hasNext()){
            GuanXi_EK guanXi_ek = iterator.next();
            if (guanXi_ek.getKnowledgeElement().getId().longValue() == knowledgeElementNode.getId().longValue()) {
                iterator.remove();
            }
        }
    }
    public static void removeEP(Event eventNode, People peopleNode) {
        List<GuanXi_EP> guanXi_epList = eventNode.getGuanXi_epList();
        // list的遍历器
        Iterator<GuanXi_EP> iterator = guanXi_epList.iterator();
        while(iterator.hasNext()){
            GuanXi_EP guanXi_ep = iterator.next();
            if (guanXi_ep.getPeople().getId().longValue() == peopleNode.getId().longValue()) {
                // 逻辑移除
                iterator.remove();
            }
        }

        // String[] peopleArray =  eventNode.getPeople().split(",");

    }

}
